package com.whzykj.model;

import java.util.List;

import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.ehcache.CacheInterceptor;
import com.jfinal.plugin.ehcache.CacheKit;
import com.jfinal.plugin.ehcache.CacheName;
import com.jfinal.plugin.ehcache.EvictInterceptor;
import com.whzykj.common.SystemRunParamCache;
import com.whzykj.jfinal.TableBind;

@TableBind(name="system_run_param",pk="id")
public class SystemRunParam extends Model<SystemRunParam>{
	private static final long serialVersionUID = 1L;
	public static final SystemRunParam me=new SystemRunParam();
	
	/**
	 * 获取所有运行参数的列表，用于放入到缓存中
	 * @return
	 */
	public List<SystemRunParam> loadRunParamCache(){
		return SystemRunParam.me.find("select * from system_run_param");
	}
	
	/**
	 * 更新运行参数的时候，更新缓存
	 * @param param
	 * @return
	 */
	public boolean updateParam(SystemRunParam param){
		boolean update=false;
		try {
			update = param.update();
			if(update){
				CacheKit.remove("paramCache", "param");
				SystemRunParamCache.cache.loadCache();
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return update;
	}
}
